# coding=utf-8
import json

from django.db import transaction
from rest_framework.views import APIView
from rest_framework import generics
from apps.system.models import Option, Area
from apps.system.serializers import OptionSerializer
from apps.system.filters import AreaFilter
from utils import response_ok
from .serializers import AreaSerializer


class SystemDictView(APIView):

    def get(self, request):
        dict = {
            'activity_theme': OptionSerializer(Option.objects.filter(type=Option.ACTIVITY_THEME), many=True).data
        }
        return response_ok(dict)


class AreaView(generics.ListAPIView):
    serializer_class = AreaSerializer
    queryset = Area.objects.filter()

    def filter_queryset(self, queryset):
        f = AreaFilter(self.request.GET, queryset=queryset)
        return f.qs

    def paginate_queryset(self, queryset):
        return None
